
package org.apache.solr.response.transform;

import org.apache.solr.common.SolrDocument;

/**
 * Simple Augmenter that adds the score
 *
 * @since solr 4.0
 */
public class ScoreAugmenter extends TransformerWithContext {

    final String name;

    public ScoreAugmenter(String display) {
        this.name = display;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public void transform(SolrDocument doc, int docid) {

        if(context != null && context.wantsScores) {
            if(context.iterator != null) {
                doc.setField(name, context.iterator.score());
            }
        }
    }
}
